<?php

	$TEMP->set_file(array('handle' => DIR_IFRAME_VIEW . 'requestStudentSection.html'));
	
	$studID 	= $_GET['id'];
	$semLinkID	= $_GET['slid'];
	
	$strStudPictureName = $globalCon->getStudentPictureName($studID);
	$strName			= $strStudPictureName['name'];
	$strAccNo			= $strStudPictureName['stud_no'];
	$courseID			= $strStudPictureName['course_idPK'];
	$courseCode			= $strStudPictureName['course_code'];
	$courseDesc			= $strStudPictureName['course_desc'];
	
	$studentSection = $globalCon->getStudentSection($studID, $semLinkID, $activeYear);
	$sectionID		= $studentSection['section_idPK'];
	$sectionDesc	= $studentSection['section_desc'];
	$sectionSemID 	= $studentSection['stud_sem_idPK'];
	
	$profSectionList = $STUD->getStudentChangeSectionActive($studID, $courseID, $semLinkID, $activeYear);
	
	if ( isset($_POST['accept_status']) ) {
		$if_error	= 0;
		$acceptstatus = _POST('accept_status');
		$txtsection	  = _POST('txtsection');
		if ( empty($txtsection) )	 { $if_error++; $_txtsection = REQ_FIELD; }
		if ( $if_error == 0 ) {
			if ( $acceptstatus == 'Y' ) {
				$STUD->updateStudentSection($txtsection, $sectionSemID, $courseID, $semLinkID);
			}
			$STUD->updateStudentChangeSection($profSectionList['scs_idPK'], $acceptstatus, $strAccNo);
			$if_display = 1;
		}
	}
	else {
		$if_display	 = 0;
		$if_error	 = 0;
		$_txtsection = '';
	}
	$defaultSections = $STUD->getDefaultSections($courseID, $profSectionList['section_idFK'], $semLinkID);

	$inputSectionList = '<input type="hidden" name="txtsection" id="txtsection" value="' . $profSectionList['section_idFK'] . '"><span class="semester-page-width"><strong>'. $defaultSections[0]['section_desc'] . '</strong></span>';
	
	$TEMP->set_var(array('section'		=> $inputSectionList,
						 'section_desc'	=> $sectionDesc,
						 'course_label'	=> $courseDesc . ' (' . $courseCode . ')',
						 'sy_label'		=> $__SYR__,
						 'name'			=> $strName,
						 'if_display'	=> $if_display
						));

?>